package com.hc.demo.controller;

import com.hc.common.bean.Result;
import com.hc.common.bean.ResultUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/authority")
public class AuthorityController {

    @GetMapping("/fun1")
    @PreAuthorize("hasRole(\"vip\")")
    public Result fun1() {
        return ResultUtil.success("fun1");
    }

    @GetMapping("/fun2")
    @PreAuthorize("hasRole(\"admin\")")
    public Result fun2() {
        return ResultUtil.success("fun2");
    }

    @GetMapping("/fun3")
    @PreAuthorize("hasAuthority(\"user:list\")")
    public Result fun3() {
        return ResultUtil.success("fun3");
    }

    @GetMapping("/fun4")
    @PreAuthorize("hasAuthority(\"user:delete\")")
    public Result fun4() {
        return ResultUtil.success("fun4");
    }

}
